home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 051-075 / scopedisk55 / dirk2 / adjust.c < prev    next >
C/C++ Source or Header  |  1995-03-18  |  4KB  |  140 lines

  1.  
  2. /***************************************************************************
  3.     1/89
  4.  
  5.         DIRK v2.0 -- Tune workbench colors to system performance
  6.  
  7.         Copyright (C) 1989 by Daniel Elbaum
  8.  
  9.         This software is freely redistributable provided that:
  10.         the four files which comprise it (dirk, dirk.doc, dirk.h,
  11.         adjust.c, main.c, sys, window.c) remain intact; all
  12.         copyright notices contained in any of the aforementioned
  13.         files remain intact; and no fee beyond reasonable remuneration
  14.         for collation and distribution be charged for use and/or
  15.         distribution.
  16.  
  17. ***************************************************************************/
  18.  
  19.  
  20. #include "dirk.h"
  21.  
  22. #define T_LEFT   (6)    /* centers text nicely              */
  23. #define T_HEIGHT (10)
  24. #define T_TOP    (WINHT1+4)
  25.  
  26. void
  27. setcolor(sp, tm, g_f)
  28. register struct Screen *sp;
  29. ULONG tm;
  30. t_gf *g_f;
  31. {
  32.     register f, db, t;
  33.     int tr, tw;
  34.     int dr, dg, db;     /* detail red, blue, green  */
  35.     int br, bg, bb;     /* bkgnd red, blue, green   */
  36.     ULONG mu, fm;
  37.     ULONG amtfree();
  38.  
  39.     if (g_f->dstog){
  40.         tqlen(&tr, &tw);
  41.  
  42.         f=CMAX-(tr+tw)/g_f->gran;
  43.         if (f<g_f->dsmin) f=g_f->dsmin;
  44.         if (f>g_f->dsmax) f=g_f->dsmax;
  45.         if ((t=tr/g_f->gran+f)>CMAX) t=CMAX;
  46.         /* Detail and Block pens seem to be reversed    */
  47.  
  48.         if ((dr=t+g_f->bd_r)>CMAX) dr=CMAX;
  49.         if ((dg=t+g_f->bd_g)>CMAX) dg=CMAX;
  50.         if ((db=t+g_f->bd_b)>CMAX) db=CMAX;
  51.     }
  52.  
  53.     /* val = minval + ((mused / mtotal) * (maxval - minval)) */
  54.     if (g_f->bstog){
  55.         fm=amtfree();
  56.         mu=tm-fm;
  57.         br=g_f->lb_r+(mu*g_f->db_r)/tm;
  58.         bg=g_f->lb_g+(mu*g_f->db_g)/tm;
  59.         bb=g_f->lb_b+(mu*g_f->db_b)/tm;
  60.     }
  61.  
  62.     Forbid();
  63.     if (g_f->dstog) SetRGB4(sp->ViewPort, sp->BlockPen, dr, dg, db);
  64.     if (g_f->bstog) SetRGB4(sp->ViewPort, sp->DetailPen, br, bg, bb);
  65.     Permit();
  66. }
  67.  
  68. #define N_TEXT  (8)
  69. typedef struct IntuiText t_it;
  70.  
  71. void
  72. fillwin(wp)
  73. struct Window *wp;
  74. {
  75.     register i;
  76.     int tr, tw;
  77.     ULONG cavail, favail;
  78.     char trbu[24], twbu[24], cabu[24], fabu[24];
  79.     t_it *ita[N_TEXT];
  80.  
  81.     memset(ita, 0, sizeof(ita));
  82.     for (i=0; i<N_TEXT; ++i)
  83.         if (!(ita[i]=(t_it *)AllocMem(sizeof(t_it), MEMF_PUBLIC|MEMF_CLEAR)))
  84.             break;
  85.     if (i<N_TEXT){
  86.         for (i=0; i<N_TEXT; ++i)
  87.             if (ita[i]) FreeMem(ita[i], sizeof(t_it));
  88.         return;
  89.     }
  90.     Forbid();
  91.     cavail=AvailMem(MEMF_CHIP);
  92.     favail=AvailMem(MEMF_FAST);
  93.     Permit();
  94.  
  95.     tqlen(&tr, &tw);
  96.     sprintf(trbu, "Ready:    %3.3d", tr);
  97.     sprintf(twbu, "Waiting:  %3.3d", tw);
  98.     sprintf(cabu, "Chip: %7.7d", cavail);
  99.     sprintf(fabu, "Fast: %7.7d", favail);
  100.  
  101.     ita[0]->FrontPen=wp->BlockPen;
  102.     ita[0]->BackPen=wp->DetailPen;
  103.     ita[0]->DrawMode=JAM2;
  104.  
  105.     for (i=1; i<N_TEXT; ++i)
  106.         memcpy(ita[i], ita[0], sizeof(t_it));
  107.  
  108.     ita[0]->TopEdge=0;
  109.     ita[0]->IText="2.0  (C) 1989";
  110.     ita[0]->NextText=ita[1];
  111.     ita[1]->TopEdge=T_HEIGHT;
  112.     ita[1]->IText="Daniel Elbaum";
  113.     ita[1]->NextText=ita[2];
  114.     ita[2]->TopEdge=T_HEIGHT*3;
  115.     ita[2]->IText="    Tasks";
  116.     ita[2]->NextText=ita[3];
  117.     ita[3]->IText=trbu;
  118.     ita[3]->TopEdge=T_HEIGHT*4;
  119.     ita[3]->NextText=ita[4];
  120.     ita[4]->IText=twbu;
  121.     ita[4]->TopEdge=T_HEIGHT*5;
  122.     ita[4]->NextText=ita[5];
  123.     ita[5]->IText="  Memories";
  124.     ita[5]->LeftEdge=6;
  125.     ita[5]->TopEdge=T_HEIGHT*7;
  126.     ita[5]->NextText=ita[6];
  127.     ita[6]->IText=cabu;
  128.     ita[6]->TopEdge=T_HEIGHT*8;
  129.     ita[6]->NextText=ita[7];
  130.     ita[7]->IText=fabu;
  131.     ita[7]->TopEdge=T_HEIGHT*9;
  132.     ita[7]->NextText=NULL;
  133.  
  134.     PrintIText(wp->RPort, ita[0], T_LEFT, T_TOP);
  135.     for (i=0; i<N_TEXT; ++i)
  136.         FreeMem(ita[i], sizeof(t_it));
  137.     return;
  138. }
  139.  
  140.